package top.jiug.file.config;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
@Configuration
public class GetConfig implements Serializable {

    // 页面登录账号密码
    @Value("${app.username}")
    private  String username;
    @Value("${app.password}")
    private  String password;

    // 文件上传密钥
    @Value("${app.file-secret-key}")
    private String fileSecretKey;
    private Map<String,String> fileSecretKeyMap;

    public Map<String, String> getFileSecretKeyMap() {
        if(fileSecretKeyMap==null){
            fileSecretKeyMap = new HashMap<>();
            String[] md5Object = fileSecretKey.split(";");
            for (int i = 0; i < md5Object.length; i++) {
                String[] md5KV = md5Object[i].split(",");
                fileSecretKeyMap.put(md5KV[1],md5KV[0]);
            }
        }
        return fileSecretKeyMap;
    }

    // 文件上传基础路径
    @Value("${app.base-path}")
    private String basePath;

    // 文件访问域名
    @Value("${app.domain}")
    private  String domain;



}

